#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

#AC_PREREQ([2.63])
AC_INIT([broomie], [0.1.9], [kimura.shunya@gmail.com])
AC_CONFIG_SRCDIR([config.h.in])

AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE(broomie, 0.1.9)

# Options
AC_ARG_ENABLE(interface,
        AS_HELP_STRING([--enable-interface], [build interface]),
        enable_interface="$enableval", enable_interface="no"
        )
AM_CONDITIONAL(ENABLE_INTERFACE, test "$enable_interface" = "yes")

AC_ARG_ENABLE(test,
        AS_HELP_STRING([--enable-test], [build test tools. need gtest.]),
        enable_test="$enableval", enable_test="no"
        )
AM_CONDITIONAL(ENABLE_TEST, test "$enable_test" = "yes")


# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_CPP
AC_LANG(C++)
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
#AC_PROG_RANLIB

# Checks for libraries.
AC_PROG_LIBTOOL
AC_CHECK_LIB(tokyocabinet, tchdbnew)

# Checks for header files.

AC_CHECK_HEADER(tcutil.h, true, AC_MSG_ERROR([tcutil.h is required]))
AC_CHECK_HEADER(tchdb.h, true, AC_MSG_ERROR([tchdb.h is required]))

if [ test $enable_interface = "yes" ]; then
   AC_CHECK_LIB(fcgi, FCGI_Accept)
   AC_CHECK_HEADER(fcgi_stdio.h, true, AC_MSG_ERROR([fcgi_stdio.h is required]))
fi

if [ test $enable_test = "yes" ]; then
   AC_CHECK_LIB(gtest, main)
   AC_CHECK_HEADER(gtest/gtest.h, true, AC_MSG_ERROR([gtest/gtest.h is required]))  
fi


# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDC
AC_HEADER_STDBOOL
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T
AC_FUNC_CLOSEDIR_VOID
AC_FUNC_STAT
AC_HEADER_DIRENT
AC_PROG_RANLIB
AC_STRUCT_TM


# Checks for library functions.

AC_CHECK_FUNCS([mkdir rmdir strchr strrchr strstr])

AC_CONFIG_FILES([Makefile
                 src/Makefile])
AC_OUTPUT
